package com.shrcl.engineerprocess.domain.proxy;

import com.google.gwt.user.client.rpc.IsSerializable;
import com.shrcl.engineerprocess.domain.proxy.EngineerCertificationAction;

public class EngineerCertificationManager implements IsSerializable {
  public static Boolean isActionValid(final EngineerCertificationAction action, final String state) {
    if(action==null||state==null) return false;
    switch(action){
    	case update:{
    		return "created".equals(state);
    	}
    	case commit:{
    		return "created".equals(state);
    	}
    	case checkTimer:{
    		return "effective".equals(state);
    	}
    	case checkExpiredTimer:{
    		return "abouttoexpired".equals(state)||"effective".equals(state);
    	}
    	case renew:{
    		return "expired".equals(state)||"effective".equals(state);
    	}
    	case forceClosed:{
    		return "expired".equals(state)||"abouttoexpired".equals(state)||"effective".equals(state);
    	}
    	default:
    		return false;
    }
    
  }
  
  public static Boolean isActionValid(final EngineerCertificationAction action, final Enum<?> state) {
    return isActionValid(action,state.name());
    
  }
}
